package com.ming.test;

import javax.swing.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class MyJFrame2 extends JFrame implements KeyListener {
    public MyJFrame2(){
        this.setSize(603,680);

        //设置界面的标题
        this.setTitle("拼图单机版 v1.0");

        //设置界面始终置顶
        this.setAlwaysOnTop(true);
        //创建按钮
        this.addKeyListener(this);
        //设置界面居中
        this.setLocationRelativeTo(null);

        //取消默认的居中方式
        this.setLayout(null);
        //设置关闭模式
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        //可视化
        this.setVisible(true);
    }

    @Override
    public void keyTyped(KeyEvent e) {

    }

    @Override
    public void keyPressed(KeyEvent e) {
        System.out.println("按下不松");
    }

    @Override
    public void keyReleased(KeyEvent e) {
        System.out.println("松开");
        int keyCode = e.getKeyCode();
        System.out.println(keyCode);
        /*if(keyCode == 65){
            System.out.println("A");
        }else if(keyCode == 66){
            System.out.println("B");*/
    }
}
